<?php 
require_once('Admin/Common/template/inc_admin.php');

$sql = "select * from newstype";

if($_REQUEST['key']) {
   $key = trim($_REQUEST['key']);
   $sql = $sql." where newstype like '%{$key}%'";
}

$result = mysql_query($sql);
$totalrows = mysql_num_rows($result);

$page = $_REQUEST['page'];

if(!isset($page)) $page = 1;

if($_POST['search']) $page = 1;

$rowsperpage = 7;

$start = ($page-1) * $rowsperpage;

$sql .= " limit {$start}, {$rowsperpage}";

$result = mysql_query($sql) or die('查询失败！'.mysql_error());
?>
<div id="content">
   <div class="inner" style="min-height:1200px;">

      <div align=center>
         <h1 style="text-align:center">
            新闻类别列表</h1>

            <button class="btn btn-default" style="font-family: 微软雅黑; position: relative;left: 10% ;width:80px;height:40px"><a href="admin.php?c=newstype&m=form">添加类别</a></button>

         </center>
         <div class="container-fluid control-label  col-md-12 ">


            <form method=post action="admin.php?c=news&m=search" enctype="multipart/form-data" class="form-horizontal">
               <div class="form-group">
                  <label for="newsname" class="control-label col-md-8 col-md-offset-1">请输入新闻名:</label>
                  <div class="col-md-2 " >
                     <input type="text" name="key" class="form-control" id="newsname">
                  </div>
                  <input type="submit" class="btn btn-success" value="搜索">
               </div>
            </form>

            <table align="center" width="80%" border=1>
               <tr>
                  <th>序号</th>
                  <th>新闻类别名称</th>
                  <th>操作</th>
               </tr>
               <?php
               while($row = mysql_fetch_assoc($result)){
                  echo '<tr>';
                  echo '<td>'.$row['ntid'].'</td>';
                  echo '<td>'.$row['newstype'].'</td>';
                  echo '<td><a href="admin.php?c=newstype&m=editnewstype&id='.$row['ntid'].'">  修改</a> |
                  <a href="admin.php?c=newstype&m=delnewstype&id='.$row['ntid'].'" onClick="return confirm(\'确定要删除吗？
                  \');">删除</a></td>';
                  echo '</tr>';
               }
               echo '</table>';

               ?>

            </table>
         </div>
      </div>
   </div>
</div>

<nav class="navbar navbar-fixed-bottom">
   <a href="#" "><img align="right"  src="./assets/images/gotop.jpg" alt="回顶部" width="50" height="50"></a>
</nav>